home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung 2 / Power-Programmierung CD 2 (Tewi)(1994).iso / c / library / dos / diverses / tctnt / bioskeyx.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-27  |  1.3 KB  |  50 lines

  1. /* BIOSKEYX.C: Reading the enhanced keyboard's F11 & F12 keys
  2.  
  3.      The bioskey() example can be modified to recognize the F11 and F12
  4.      extended keys. This requires the use of functions 16 and 17; function
  5.      17 (0x11) gets an enhanced keyboard's status and function 16 (0x10)
  6.      reads a character from an enhanced keyboard.
  7.  
  8.      NOTE:  Requires enhanced keyboard and corresponding BIOS
  9. */
  10.  
  11. #include <stdio.h>        // for printf()
  12. #include <bios.h>            // for bioskey()
  13. #include <ctype.h>        // for isalnum()
  14.  
  15. #define RIGHT  0x01
  16. #define LEFT   0x02
  17. #define CTRL   0x04
  18. #define ALT    0x08
  19.  
  20. //*******************************************************************
  21. int main(void)
  22. {
  23.     int key, modifiers;
  24.  
  25.     // function 17 returns 0 until a key is pressed
  26.     while (bioskey(17) == 0);
  27.  
  28.     // function 16 returns the key that is waiting
  29.     key = bioskey(16);
  30.  
  31.     // use function 2 to determine if shift keys were used
  32.     modifiers = bioskey(2);
  33.     if (modifiers) {
  34.         printf("[");
  35.         if (modifiers & RIGHT) printf("RIGHT");
  36.         if (modifiers & LEFT)  printf("LEFT");
  37.         if (modifiers & CTRL)  printf("CTRL");
  38.         if (modifiers & ALT)   printf("ALT");
  39.         printf("]");
  40.     }
  41.  
  42.     // print out the character read
  43.     if (isalnum(key & 0xFF))
  44.         printf("'%c'\n", key);
  45.     else
  46.         printf("%#02x\n", key);
  47.  
  48.     return 0;
  49. } // end of main()
  50.